import { defineStore } from "pinia";
import requests from "../utils/requests";

const useFeedbckStore=defineStore('feedback',{
	state:()=>({
		form:{
			radiovalue:'故障',
			feedbck_content:'',
			contact:''
		}
	}),
	actions:{
		async feedBack(){
			const res=await requests({
				url:'/base/feedback/',
				method:'post',
				data:{
					username:uni.getStorageSync('username'),
					type:this.form.radiovalue,
					content:this.form.feedbck_content,
					contact:this.form.contact
				}
			})
			if (res.code===200){
				this.form.radiovalue='故障'
				this.form.feedbck_content=''
				this.form.contact=''
				uni.$u.toast(`反馈成功`)
			}else{
				uni.$u.toast(`反馈失败，${res.error}`)
			}
		}
	}
})
export default useFeedbckStore;